package talent.controller;//package com.example.talent.controller;
//
//import cn.hutool.json.ObjectMapper;
//import com.example.talent.dto.RecommendationRequestDTO;
//import com.example.talent.dto.TalentQueryDTO;
//import com.example.talent.service.TalentService;
//import com.example.talent.vo.RecommendationVO;
//import com.example.talent.vo.TalentVO;
//import org.junit.Test;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
//import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
//import org.springframework.boot.test.mock.mockito.MockBean;
//import org.springframework.test.web.servlet.MockMvc;
//
//import java.util.Arrays;
//import java.util.List;
//
//import static javafx.beans.binding.Bindings.when;
//import static org.hamcrest.Matchers.any;
//import static org.springframework.http.RequestEntity.post;
//import static org.springframework.test.web.client.match.MockRestRequestMatchers.jsonPath;
//import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
//
//@WebMvcTest(TalentController.class)
//@AutoConfigureMockMvc
//class TalentControllerTest {
//
//    @Autowired
//    private MockMvc mockMvc;
//    @MockBean
//    private TalentService talentService;
//    private final ObjectMapper mapper = new ObjectMapper();
//
//    // 测试数据
//    private final TalentQueryDTO queryDTO = new TalentQueryDTO(2, 5, 4, 30000);
//    private final RecommendationRequestDTO requestDTO =
//            new RecommendationRequestDTO(50000, 5, 2, 5, 4);
//
//    // ================= 推荐接口测试 =================
//    @Test
//    public void recommendTalents_ShouldReturn200() throws Exception {
//        // 模拟返回数据
//        List<RecommendationVO> mockResult = Arrays.asList(
//                new RecommendationVO(1L, "张三", 10, 9, 4, 25000, 92.5, "推荐理由..."),
//                new RecommendationVO(2L, "李四", 9, 8, 5, 28000, 88.3, "推荐理由...")
//        );
//
//        when(talentService.recommendTalents(any())).thenReturn(mockResult);
//
//        // 执行请求
//        mockMvc.perform(post("/api/talent/recommend")
//                        .contentType(MediaType.APPLICATION_JSON)
//                        .content(mapper.writeValueAsString(queryDTO)))
//                .andExpect(status().isOk())
//                .andExpect(jsonPath("$[0].candidateName").value("张三"))
//                .andExpect(jsonPath("$[1].valueScore").value(88.3));
//    }
//
//    // ================= 最优组合接口测试 =================
//    @Test
//    void findOptimalTalents_ShouldOptimizeCost() throws Exception {
//        // 模拟动态规划结果
//        List<TalentVO> mockResult = Arrays.asList(
//                new TalentVO(3L, "王五", 15000, 8, 5, 4),
//                new TalentVO(4L, "赵六", 12000, 7, 6, 3)
//        );
//
//        when(talentService.findOptimalTalents(any())).thenReturn(mockResult);
//
//        mockMvc.perform(post("/api/talent/optimal")
//                        .content(mapper.writeValueAsString(requestDTO))
//                        .contentType(MediaType.APPLICATION_JSON))
//                .andExpect(status().isOk())
//                .andExpect(jsonPath("$", hasSize(2)))
//                .andExpect(jsonPath("$[0].expectedSalary").value(15000));
//    }
//
//    // ================= 详情接口测试 =================
//    @Test
//    void getTalentDetails_ShouldReturnCompleteInfo() throws Exception {
//        TalentVO mockTalent = new TalentVO(5L, "钱七", 18000, 10, 8, 5);
//        when(talentService.getTalentDetails(5L)).thenReturn(mockTalent);
//
//        mockMvc.perform(get("/api/talent/5"))
//                .andExpect(status().isOk())
//                .andExpect(jsonPath("$.id").value(5))
//                .andExpect(jsonPath("$.workExperience").value(8));
//    }
//}
